package com.test.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.test.bo.OrderBO;
import com.test.bo.PageDataBO;
import com.test.entity.Order;
import com.test.mapper.OrderMapper;
import com.test.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class OrderServiceImpl implements OrderService {

    @Autowired
    private OrderMapper orderMapper;

    @Override
    public int create(Order order) {
        return orderMapper.create(order);
    }

    @Override
    public int delete(Map<String, Object> paraMap) {
        return orderMapper.delete(paraMap);
    }

    @Override
    public int update(Map<String, Object> paraMap) {
        return orderMapper.update(paraMap);
    }

    @Override
    public PageInfo query(PageDataBO<OrderBO> pageDataBO) {
        PageHelper.startPage(pageDataBO.getPage(), pageDataBO.getPageSize());
        Map paraMap = new HashMap();
        OrderBO order = pageDataBO.getData();
        paraMap.put("startTime", order.getStartTime());
        paraMap.put("endTime", order.getEndTime());
        paraMap.put("id", order.getId());
        paraMap.put("name", order.getName());
        List<Order> list = orderMapper.query(paraMap);
        PageInfo pageInfo = new PageInfo(list);
        return pageInfo;
    }

    @Override
    public Order detail(Map<String, Object> paramMap) {
        return orderMapper.detail(paramMap);
    }

    @Override
    public int count(Map<String, Object> paramMap) {
        return orderMapper.count(paramMap);
    }


}
